<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>供应商管理详情</title>
    <link rel="stylesheet" type="text/css" href="../../lib/pagination/style/pagination.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/base.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/news/center.css"/>
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <script type="text/javascript" src="../../js/news/jquery-1.9.1.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="../../js/news/page.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/layer/layer.js?20201106"></script>
    <script src="../../lib/laydate/laydate.js"></script>
    <script src="../js/sys/citys.js" type="text/javascript" charset="utf-8"></script>
    <style>
        * {font-family: "Microsoft Yahei" !important;}
        b{
            color: red;
        }
        .head_title{
            margin-top: 10px;
            height: 40px;
            position: relative;
        }
        .head_title .title{
            margin-left: 22px;
        }
        .head_title span{
            float: none;
            /*margin-top: 9px;*/
            font-size: 22px;
            color: #333;
            display: inline-block;
            margin-left: 10px;
            vertical-align: middle;
            margin-top: -6px;
        }
        .saveBtn{
            display: block;
            float: left;
            background: url(../img/confirm.png) no-repeat;
            border: none;
            width: 70px;
            height: 29px;
            line-height: 29px;
            margin-left: 10px;
            cursor: pointer;
        }
        .resetBtn {
            display: block;
            float: left;
            background: url(../img/news/new_filling.png) no-repeat;
            border: none;
            width: 70px;
            height: 29px;
            line-height: 29px;
            margin-left: 10px;
            cursor: pointer;
        }
        .div_Btn{
            position: absolute;
            left: 43%;
            margin: 10px auto;
        }
        select{
            width: 250px;
            height: 30px;
        }
        .newTbale tr td {
            border-right: #ccc 1px solid;
            padding: 5px 30px;
        }
        input[type="text"]{
            width: 250px;
            height: 30px;
        }
        .newTbale {
            width: 85%;
            margin: 0px auto;
        }
        table {
            border-collapse: collapse;
            border-spacing: 0;
        }
        #ajaxforms{
            position: relative;
        }
        #query_uploadArr{
            border: 1px solid #ddd;
            min-height: 45px;
            max-height: 102px;
            overflow: auto;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
</head>
<body>
<!--head开始-->
<div class="head_title">
    <div class="title">
        <img src="/img/commonTheme/${sessionScope.InterfaceModel}/flow_run_title.png"><span style="">供应商管理详情</span>
    </div>
</div>
<div id="pagediv">
    <form id="ajaxforms" action="/supplier/updateSupplier">
        <table class="newTbale">
            <tr>
                <td>供应商名称:</td>
                <td><input type="text" name="supplierName" readonly="readonly" disabled="true"/><b>*</b></td>
                <td>邮政编码:</td>
                <td><input type="text" name="zipCode" disabled="true"/></td>
            </tr>
            <tr>
                <td>供应商电话:</td>
                <td><input type="text" name="phone" disabled="true"/></td>
                <td>传真号码:</td>
                <td><input type="text" name="fax" disabled="true"/></td>
            </tr>
            <tr>
                <td>创建人:</td>
                <td><input type="text" name="creator" disabled="true" /></td>
                <td>创建时间:</td>
                <td><input type="text" style="width: 252px" disabled="true" name="createTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" placeholder="请输入时间" id="startTimeOne" style="width: 260px"/></td>
            </tr>
            <tr>
                <td>供应商网址:</td>
                <td><input type="text" name="website" disabled="true"/></td>
                <td>电子邮箱:</td>
                <td><input type="text" name="email" disabled="true" /></td>
            </tr>
            <tr>
                <td>供应商地址:</td>
                <td><input type="text" name="address" disabled="true"/></td>
                <td>所在地区:</td>
                <td>
                    <select name="province" style="width: 125px" id="sheng" disabled="true">
                        <option>请选择</option>
                    </select>
                    <select name="city" style="width: 125px" id="city1" disabled="true">
                        <option>请选择</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>开户行:</td>
                <td><input type="text" name="registerBank" disabled="true"/></td>
                <td>银行账号:</td>
                <td><input type="text" name="bankAccount" disabled="true"/></td>
            </tr>
            <tr>
                <td>户名:</td>
                <td><input type="text" name="accountName" disabled="true"/></td>
                <td>备注:</td>
                <td><input type="text" name="remark" disabled="true"/></td>
            </tr>
            <tr>
                <td>附件:</td>
                <td>
                    <form id="uploadimgform" style="height: 30px;" target="uploadiframe"  action="../upload?module=attachment" enctype="multipart/form-data" method="post">
                        <input type="file" multiple="multiple" name="file" id="uploadinputimg"  class="w-icon5" style="position: absolute;opacity: 0;width: 70px;cursor:pointer;
                        filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0)">
                        <div id="query_uploadArr" name="query_uploadArr" style="display: block;width:240px;height:80px;float:left">
                        </div>
                        <%--<a id="uploadimg" style="cursor: pointer;color:#2F8AE3;line-height: 80px;margin-left:10px">附件上传</a>--%>
                    </form>
                </td>
            </tr>
        </table>
    </form>
</div>
<div class="div_Btn">
    <%--<div class="saveBtn">--%>
        <%--&lt;%&ndash;<span  onclick="ajaxforms()" style="margin-left: 32px;">保存</span>&ndash;%&gt;--%>
    <%--</div>--%>
    <div class="resetBtn" onclick="javascript:window.location.href='/supplier/showSupplier';">
        <span  style="margin-left: 32px;" >返回</span>
    </div>
</div>
</body>
<script>
    var getRequestObj=$.GetRequest();

    //        修改数据
    function  ajaxforms() {
        $.ajax({
            url: '/',//supplier/updateByPrimarySupplier
            type: 'post',
            dataType: 'json',
            data: $('#ajaxforms').serialize()+'&supplierId='+getRequestObj.supplierId,
            success: function (data) {
                if(data.flag){
                    layer.open({
                        type: 1
                        , offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                        , id: 'layerDemo' + type //防止重复弹出
                        , content: '<div style="padding: 20px 100px;">' + "修改成功!" + '</div>'
                        , btn: '确定'
                        , btnAlign: 'c' //按钮居中
                        , shade: 0 //不显示遮罩
                        , yes: function () {
                            layer.closeAll();
                            window.location.href='/supplier/showSupplier'
                        }
                    });
                }else{
                    layer.open({
                        type: 1
                        , offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                        , id: 'layerDemo' + type //防止重复弹出
                        , content: '<div style="padding: 20px 100px;">' + "修改失败!" + '</div>'
                        , btn: '确定'
                        , btnAlign: 'c' //按钮居中
                        , shade: 0 //不显示遮罩
                        , yes: function () {
                            layer.closeAll();

                        }
                    });
                }
            },
            error: function (data) {
                layer.open({
                    type: 1
                    , offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                    , id: 'layerDemo' + type //防止重复弹出
                    , content: '<div style="padding: 20px 100px;">' + "修改失败!" + '</div>'
                    , btn: '确定'
                    , btnAlign: 'c' //按钮居中
                    , shade: 0 //不显示遮罩
                    , yes: function () {
                        layer.closeAll();

                    }
                });
            }
        })
    }
    //数据回显
    $(function () {

        $.ajax({
            url:'/supplier/selectByPrimaryKey',
            data:{
                supplierId:getRequestObj.supplierId
            },
            type: 'get',
            dataType: 'json',
            success:function (json) {
                if (json.flag) {
                    $('[name="supplierId"]').val(json.object.supplierId);
                    $('[name="supplierName"]').val(json.object.supplierName);
                    $('[name="phone"]').val(json.object.phone);
                    $('[name="fax"]').val(json.object.fax);
                    $('[name="website"]').val(json.object.website);
                    $('[name="zipCode"]').val(json.object.zipCode);
                    $('[name="email"]').val(json.object.email);
                    $('[name="address"]').val(json.object.address);
                    $('[name="province"]').val(json.object.province);
                    getCity(json.object.province);
                    $('[name="city"]').val(json.object.city);
                    $('[name="registerBank"]').val(json.object.registerBank);
                    $('[name="bankAccount"]').val(json.object.bankAccount);
                    $('[name="accountName"]').val(json.object.accountName);
                    $('[name="remark"]').val(json.object.remark);
                    $('[name="creator"]').val(json.object.creator);
                    $('[name="createTime"]').val(json.object.createTime);
                    var arr = json.object.attachmentList;
                    var str1="";
                    if (json.object.attachments1 != '') {
                        for (var i = 0; i < (arr.length); i++) {
                            str1+='<div class="dech" deUrl="'+encodeURI(arr[i].attUrl)+'" style="display:block;"><a class="ATTACH_a" style="color:#2F8AE3;" NAME="'+arr[i].attachName+'*" href="<%=basePath %>download?'+encodeURI(arr[i].attUrl)+'">'+arr[i].attachName+'</a><input type="hidden" NAME="'+arr[i].attachName+'*"  class="inHidden" value="'+arr[i].aid+'@'+arr[i].ym+'_'+arr[i].attachId+',"></div>';
                        }
                        $('#query_uploadArr').append(str1);
                    };
                }
            }
        })

    })
    $(function () {
        var duanxin='';
        var flag=0;
        var sheng='<option value="">请选择</option>';
        for(var i=0;i<json.provinces.length;i++){
            sheng+='<option value="'+json.provinces[i].name+'">'+json.provinces[i].name+'</option>'
        }
        $('#sheng').html(sheng);
        $('#sheng').change(function () {
            var prov=$(this).val();
            getCity(prov)
        })
    })

    //根据省获取市
    function getCity(name) {
        var prov=name;
        var citys='<option value="">请选择</option>';
        for(var i=0;i<json.provinces.length;i++){
            if (json.provinces[i].name==prov){
                if(json.provinces[i].citys!=''&&json.provinces[i].citys!=undefined){
                    for(var j=0;j<json.provinces[i].citys.length;j++){
                        citys+='<option value="'+json.provinces[i].citys[j]+'">'+json.provinces[i].citys[j]+'</option>'
                    }
                }
            }
        }
        $('#city1').html(citys);
    }
</script>

</html>
